package com.onec.service.thread.sync;

public class ParkingCash {

    private final int cost = 1;
    private long cash;

    public ParkingCash() {
        this.cash = 0;
    }

    public synchronized void vehiclePay() {
        cash += cost;
    }

    public void close() {


        long totalAmount;
        synchronized (this){
            totalAmount = cash;
            cash = 0;
        }
        System.out.println("totalAmount:" + totalAmount);
    }
}
